<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <li class="completed" v-for="item in arr" :key="item.id">
      <div class="view">
        <input  v-model="item.completed" class="toggle" type="checkbox" />
        <label>{{item.title}}</label>
        <button class="destroy" @click="onDestroy(item.id)"></button>
      </div>
    </li>
  </ul>

</template>

<script>
import axios from 'axios'
export default {
  data () {
    return {
      newArr: []
    }
  },
  props: ['arr'],
  methods: {
    onDestroy (id) {
      axios({
        url: 'list/' + id,
        method: 'delete'
      }).then(res => {
        this.$emit('del-id', id)
      })
    }
  }

}
</script>
